import {
	ref
} from 'vue';
import * as S from "@/utils/storage.js"

export function useCache() {
	// 获取登录状态
	async function get(api,key,exp=0) {
		let res = S.getItem(key)
		console.log(res,key,'读取结果')
		if(!res){
			res = await api()
			console.log(res,13)
			S.setItem(key,res,exp)
			console.log("没走缓存")
		}else{
			console.log("走缓存了")
		}
		return res
	}
	
	return {
		get
	};
}